/**
 * module chart easypiechart
 */
(function() {
	'use strict';
	
	require.config({
		appDir: "/miwawa/",
		baseUrl: "resources/lib",
		paths: {
			"jquery.sparkline": "miwawa/1.0.2/js/jquery/sparkline/2.1.2/js/jquery.sparkline.min"
		}
	});

	define(['jquery.sparkline'], function(){
		var options = {
			bar:{
				type: 'bar',
	            width: "100%",
	            height: "82px",
	            barWidth: "10px",
	            barColor: "rgba(255,255,255,0.15)",
	            zeroColor: 'rgba(200,200,200,0.85)',
	            barSpacing: "5px",
	            disableHiddenCheck: true
			},
			line:{
				type: "line",
	            width: "100%",
	            height: "82px",
	            lineWidth: 2,
	            lineColor: "#fff",
	            fillColor: false,
	            spotRadius: 3,
	            minSpotColor: "#fafafa",
	            maxSpotColor: "#fafafa",
	            disableHiddenCheck: true
			}
		};
		
		return function(elem){
			jQuery(elem).each(function (i,n) {
		        var _opts = jQuery(this).data();
		        if(_opts.sparkline && _opts.values && _opts.sparkline.indexOf("composite") > -1){
		        	var sparkline = _opts.sparkline.replace("composite","");
		        	jQuery(this).sparkline(_opts.values, jQuery.extend({}, options[sparkline], _opts.options || {}) );
		        	jQuery(this).sparkline(_opts.values, jQuery.extend({composite:true}, options["line"]));
		        }else{
		        	jQuery(this).sparkline(_opts.values, jQuery.extend({}, options[_opts.sparkline], _opts.options || {}) );
		        }
		    });
		}
	});
	
})(this);